﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace KL.Store.Core
{
    public class Security
    {
        public static bool CheckHash(string notHashedStr, string hashedStr)
        {
            string hashedStr1 = CreateHash(notHashedStr);
            if (hashedStr.Equals(hashedStr1)) return true;
            return false;
        }

        public static string CreateHash(string notHashedStr)
        {
            SHA1 sha1 = new SHA1CryptoServiceProvider();
            byte[] notHashedBytes = System.Text.Encoding.ASCII.GetBytes(notHashedStr);
            byte[] hashedByte = sha1.ComputeHash(notHashedBytes);
            string hashedStr = System.Convert.ToBase64String(hashedByte);

            return hashedStr;
        }
    }
}
